package com.ruoyi.common.core.domain;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * @author ：zzc
 * @date ：Created in 2022/11/14 17:18
 * @version:
 */
@Data
@ApiModel("通用传参")
public class BaseDto<T> {
    @ApiModelProperty("页数 -1代表不分页")
    private Integer pageNum = 1;

    @ApiModelProperty("每页条数")
    private Integer pageSize = 10;

    @ApiModelProperty("排序 (eg: id asc, nickName desc)")
    private String sort;

    @ApiModelProperty("实际参数")
    @NotNull(message = "param不能为空")
    @Valid
    private T param;

    public String getOrderBy() {
        if (StrUtil.isNotBlank(sort)) {
            return StringUtils.toUnderScoreCase(sort);
        }
        return "";
    }
}
